package cn.binarywang.tools.generator;

import cn.binarywang.tools.generator.base.GenericGenerator;
import cn.binarywang.tools.generator.event.CarEventTypeEnum;

import java.util.Random;

/**
 * Created by liuf on 2020/12/9.
 */
public class CarEventGenerator extends GenericGenerator {
    private static CarEventGenerator instance = new CarEventGenerator();


    public static GenericGenerator getInstance() {
        return instance;
    }

    private static Random random = new Random();

    /**
     * 随机指定车牌中字母的数量
     * 根据当前的规则，车牌中字母的数量为0，1，2
     * @return
     */
    public static int getIndex() {
        return random.nextInt(CarEventTypeEnum.values().length);
    }
    /**
     * 车牌号生成
     * @return
     */
    @Override
    public  String generate() {
        return CarEventTypeEnum.getCode(getIndex()).getText();
    }

    /**
     * 事件随机
     * @return
     */
    public static CarEventTypeEnum getCarEvent() {
        return CarEventTypeEnum.getCode(getIndex());
    }


}
